#ifndef MAIN_INA228_H_
#define MAIN_INA228_H_

#define INA228_SLAVE_ADDRESS		0x40                //I2C设备通讯地址
#define INA228_ID_NUM               0x2281              //ina228的ID

#define INA228_CONFIG			    0x00                //配置
#define INA228_ADC_CONFIG		    0x01                //ADC 配置
#define INA228_SHUNT_CAL		    0x02                //分流校准
#define INA228_SHUNT_TEMPCO		    0x03                //分流温度系数
#define INA228_VSHUNT			    0x04                //分流电压测量
#define INA228_VBUS			        0x05                //总线电压测量
#define INA228_DIETEMP			    0x06                //温度测量
#define INA228_CURRENT			    0x07                //电流结果
#define INA228_POWER			    0x08                //功率结果
#define INA228_ENERGY			    0x09                //电能结果
#define INA228_CHARGE			    0x0A                //电荷结果
#define INA228_DIAG_ALRT		    0x0B                //诊断标志和警报
#define INA228_SOVL			        0x0C                //分流过压阈值
#define INA228_SUVL			        0x0D                //分流欠压阈值
#define INA228_BOVL			        0x0E                //总线过压阈值
#define INA228_BUVL			        0x0F                //总线欠压阈值
#define INA228_TEMP_LIMIT		    0x10                //温度高于上限阈值
#define INA228_PWR_LIMIT		    0x11                //功率高于上限阈值
#define INA228_MANUFACTURER_ID	    0x3E                //制造商 ID
#define INA228_DEVICE_ID		    0x3F                //器件 ID

int ina228_init(uint8_t i2c_master_port);

float ina228_voltage(uint8_t i2c_master_port);
float ina228_dietemp(uint8_t i2c_master_port);
float ina228_shuntvoltage(uint8_t i2c_master_port);
float ina228_current(uint8_t i2c_master_port);
float ina228_power(uint8_t i2c_master_port);
float ina228_energy(uint8_t i2c_master_port);
float ina228_charge(uint8_t i2c_master_port);
void ina228_reset_acc(uint8_t i2c_master_port);

void ina228_set_config(uint8_t i2c_master_port);
void ina228_set_adc_config(uint8_t i2c_master_port);
void ina228_set_shunt_cal(uint8_t i2c_master_port);
void ina228_task(void *param);
void ina228_timer_fun(unsigned long data);

#endif
